// api.js
import { reqloading, req } from '../plugins/request'

export function getcustombook () {
  return reqloading({ // 需要loading加载
    url: '/user/customBook/',
    method: 'get'
  })
}

export function getHotbook () {
  return req({
    url: '/user/hotbook/',
    method: 'get'
  })
}

export function getAllbook () {
  return req({
    url: '/user/books/',
    method: 'get'
  })
}

export function getAllbookPage (page, pageSize) {
  return req({
    url: `/user/books/?page=${page}&pageSize=${pageSize}`,
    method: 'get'
  })
}
// 详情接口

export function getDetailbook (id) {
  return reqloading({ // 需要loading加载
    url: `/user/books/${id}/`,
    method: 'get'
  })
}

export function collectbook (data) {
  return req({ // 需要loading加载
    url: '/user/collect/',
    method: 'post',
    data: data
  })
}

export function showCollectbook () {
  return req({ // 需要loading加载
    url: '/user/collect/',
    method: 'get'
  })
}

export function isCollect (id) {
  return req({ // 需要loading加载
    url: `/user/iscollect/${id}/`,
    method: 'get'
  })
}

// 登录注册接口

export function login (data) {
  return req({ // 需要loading加载
    url: '/user/login/',
    method: 'post',
    data: data
  })
}

export function regUser (data) {
  return reqloading({ // 需要loading加载
    url: '/user/reguser/',
    method: 'post',
    data: data
  })
}

// 所有书籍查询
export function bookSearch (data) {
  return reqloading({ // 需要loading加载
    url: '/user/bookparams/',
    method: 'get',
    params: data
  })
}

export function borrowBook (data) {
  return reqloading({ // 需要loading加载
    url: '/user/borrow/',
    method: 'post',
    data: data
  })
}

export function getBorrowBook () {
  return reqloading({ // 需要loading加载
    url: '/user/borrow/',
    method: 'get'
  })
}

// 个人信息页面

export function getUserInfo () {
  return reqloading({ // 需要loading加载
    url: '/user/userinfo/',
    method: 'get'
  })
}

export function putUserInfo (data) {
  return reqloading({ // 需要loading加载
    url: '/user/userinfo/',
    method: 'put',
    data: data
  })
}

export function getReqBook () {
  return reqloading({ // 需要loading加载
    url: '/user/reqBook/',
    method: 'get'
  })
}

export function reqBook (data) {
  return reqloading({ // 需要loading加载
    url: '/user/reqBook/',
    method: 'post',
    data: data
  })
}

export function saveClick (id) {
  return reqloading({ // 需要loading加载
    url: `/user/saveClick/${id}/`,
    method: 'post'
  })
}
